﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CNVP.JShop.UI;

namespace CNVP.JShop.Web.Admin.CommonWindows
{
    public partial class ProvinceArray : AdminPage
    {
        string ProvinceArrayCodeValue = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        public string DeliveryProvince()
        {
            string html = string.Empty;
            html += liGroup("华东");
            html += liGroup("华北");
            html += liGroup("华中");
            html += liGroup("华南");
            html += liGroup("东北");
            html += liGroup("西北");
            html += liGroup("西南");
            return html;
        }

        private string liGroup(string RangeName_Str)
        {

            string groupValue = string.Empty;
            string AddTr = string.Empty;
            var list = new BLL.CNVP_Province().GetAll_CNVP_Province("RangeName='" + RangeName_Str + "' order by code");
            if (list != null && list.Count > 0)
            {
                //for (int i = 0; i < list.Count; i++)
                //{
                //    groupValue += list[i].Code + ",";
                //}
                //groupValue = groupValue.Substring(0, groupValue.Length - 1);
                AddTr += "<li>";
                //AddTr += "	<span class=\"group-label\">";
                //AddTr += "		" + RangeName_Str + " <input name=\"J_Group\" id=\"J_Group_" + RangeName_Str + "\" type=\"checkbox\" value=\"" + groupValue + "\" onclick=\"selectAll('" + RangeName_Str + "')\" /></span>";
                AddTr += "	<span class=\"name\">";
                for (int i = 0; i < list.Count; i++)
                {
                    string strCheck = "";
                    ProvinceArrayCodeValue = Request.Params["ProvinceArrayCodeValue"];
                    if (!string.IsNullOrEmpty(ProvinceArrayCodeValue))
                    {
                        string[] ValueArray = ProvinceArrayCodeValue.Split(Convert.ToChar("|"));
                        for (int k = 0; k < ValueArray.Length; k++)
                        {
                            if (list[i].Code == ValueArray[k])
                            {
                                strCheck = " checked=\"checked\" ";
                            }
                        }
                    }
                    AddTr += "<input name=\"J_Province\" id=\"J_Province_" + list[i].Code + "\" type=\"checkbox\" " + strCheck + " value=\"" + list[i].Code + "\" />";
                    AddTr += "<span id=\"Province_" + list[i].Code + "\">" + list[i].Name + "</span>";
                }
                AddTr += "</span>";
                AddTr += "</li>";
            }
            return AddTr;
        }
    }
}